


# Both the C27 and L1 Query restrict WHERE CLAUSE upon the "Child Signature".  Therefore, let's make the database revolve around them.
!!! TODO: When calculating the "Context Signature" I believe that the "Character" should be included as part of the Hash.  
	That way it doesn't matter what way the cardinality chain is positioned.  
	The database would work for every lanuage because the "Child Signatures" would control what is in context.  
	Even an "Empty Context" signature should contain the "Character Code" for which it is empty.
	Currently it doesn't matter so much because I am using a Standard Cardinality Chain, which means that I can't handle other languages yet.

!!! TODO: Double check that L1 Query is supposed to Query on L1, or maybe the "Signature" instead..
	In most cases, the L1 is the Signature.  But now I am thinking that the "L1 Column" is only part of the C27.
	We need another 
# When the database is reset, the "my.cortex" file must contain a stucture of all the "Character Rows" and "Character Indexes" ahead of time.

# Every time a new row is inserted.
	* Inspect whether there is a <ChildSignature> for the corresponding <Character>.  
		- If a <ChildSignature> is new, 
			- Must be inserted (within the <Character> structure" alpha numerically.
			- [INDEX_CHARACTER] will be sorted alpha numerically to match the <Character> Structure.
			- All of the "Character Indexes" in [INDEX_CHARACTER] will need to be INCREMENTED with "BYTE OFFSET" if they come after the row which is being inserted (alpha-numerically).
			- The Child Signature should be inserted into the file (with BYTE Offsets) before attempting to insert the given <RowObject>
				- It is therefore possible to have a "Child Signature" without having any <RowObject>, only temporary though (unless computer is un-plugged).
			- [INDEX_CHARACTER] will need 1 or more "BYTE Offsets" recalculated.  This will occur for any <Character> that is at (or beneath) the targetted <Character> object.
		- If a <ChildSignature> NOT new,
			- ALL <RowObject>'s will be inserted as if the <ChildSignature> is NOT new.  Even if it is new, the <ChildSignature> would have been inserted prior to the <RowObject>.

	* The "Child Indexes" must be recalculated to accomodate the new "Structure Size"
	* The"Character Indexes" must be re-calculated to accomodate the new "Stucture Size".
	* The C27 indexes have to be re-sorted.
	* The Child indexes have to be re-sorted.
	
# The Character Rows must be sorted alpha numerically to match the indexes.  That will let us more efficiently figure out which Rows need to be re-calculated for the "Byte Offset"

# For the same reason, the "Child Containers" will need to be sorted alpha-numerically to match the indexes.

# All of the "Rows" contain Auto-increment ID's.  Therefore there is no need to calculate "Byte Offsets" anymore.  (they are all relative).
	"Row Signatures" do not need to be kept in alpha-numeric order.  The indexes will do just fine.

# Only 1 Cortex Object is needed... and therefore only 1 [INDEX_CHARACTER].
	- The Cortex Object is set once with a "resetDatabase" command and it will index all of the character codes ahead of time.
	- Will fail when the system starts up and it can't find a valid "Cortext Stucture".
	- The stucture will NOT be NESTED.  Because the inner containters have a dynamic size, we wouldn't be able to load the STRUCT into memory.  

# All Data Structures must exist "on top" without including any nested object.  It is not like an XML file... there are no Closing Tags!  
	We need to read the Structs into Memory, then we can find the location of other stucts. Throw an exception if we don't read what we were expecting from the "Byte Offset".

# Some of the containers with <*> mean that you might not have a <RowObject> or a <ChildSignature> relative to the parent.  
	However, we sill need "Indexes".  The Indexes can be empty though.  The Parent Object will therefore contain exactly 1 "Index Object".
	
# Near the header of the <Cortex> struct there will be a tally of the number of BYTES Offset. 
	After inserting rows, etc... the last thing that will get incremented is this value (in the header).
	When we are opening the file we can check to see if the "file size" matches what is in our Tally.
	If it doesn't match, then we know that there has been some type of file corruption.  We can run the software with a -repair command-line switch or something. (worry about that later).
	It will probably be helpful to also include the "Last Tag" worked on.  If someone unplugged their computer in the middle of an operation, we would be able to speed up the time it takes to find the culprit.

# Next to each "INDEX_DECLARATION" there will be a BYTE count letting you know how far to advance the File Handle (relative to the Parent).

# Next to each "Array Element" there will be a BYTE Count letting you know how many Bytes that Element contains (including all of the Sub-containers). 



# All of these symbols/values are relative to the parent.
------------------------------------------------------------
[x] = Index Number (like array indexes)
(x) = Number of elements contained in collection
<*> = Indicates Zero or more elements
<+> = Indicates 1 or more elements
<1> = Indicates EXACTLY 1 element

# Here is how we will organize the structures.  There are no "closing tags".  
	We can calculate checksums and use other techniques to determine corruption though.
----------------------------------------------------------------------------------------------------------------------------------------------
<1>Sruct:<Cortex> 				Contains [INDEX_CHARACTER] + 3 or more <Character> Objects + Total Number of Bytes (calculated).
	<1>Sruct:[INDEX_CHARACTER] 		(Character COUNT) + Character Index WITH Byte Offsets
	<+>Sruct:<Character> 			Contains [INDEX_CHILDREN] + 1 or more <ChildSignature> objects.
		<1>Sruct:[INDEX_CHILDREN] 	(Child Signatures COUNT) + Child Index WITH Byte Offsets
		<*>Sruct:<ChildSignature>	Contains [ROW_INDEX] + 1 or more <RowObject>
			<1>Sruct:ROW_INDEX]	(Row COUNT) + Row Index (only Array Indexes Needed)
			<*>Sruct:<RowObject>	Just a regular CSV-type column stucture with an "Auto-Increment" ID (always inserted at bottom).
----------------------------------------------------------------------------------------------------------------------------------------------

	
	
	
# Here is an example of how the structure should be organized conceptually.  
	However, we are going to use C-Structs to create the BYTES/CHARACTERS within the "text file".  It won't really be human readable.
	Although, we could certainly build the file exactly how we wanted and therefore avoid the Sructs.  We could use "Line Breaks" and "Tabs" as delimeters.
	Not a Bad idea actually... I can use "TextPad" to type in the "Byte Offset" for debugging.
----------------------------------------------------------------------------------------------------------------------------------------------
<cortex:start> (header / MIME Type)
(349023 Bytes)  ... A Tallied "Byte Count" to match the File Size (when there is no corruption).

CHARACTER_INDEXES (3)	
	33[0] (0 Bytes)
	101[1] (1477 Bytes)
	116[2] (18456 Bytes)
	....................................................................................................................................................................................................................................
	Char[0] 33 (3436 Bytes)
	CHILD_INDEXES (3)
			abcdef[0] (0 Bytes)
			gerfd3[1] (346 Bytes)
			mnopqc[2] (7834 Bytes)
			==========================================================================================================================================================================================================================================================================================================================================
			Child[0] abcdef	(85924 Bytes)	
						ROW_INDEXES (4)
								abc[0]		abceff[2]	addfzt [3]	etc.		etc.
								bbb[3]		saffa3[3]	bf4nnj [1]	etc.		etc.
								cde[2]		sdff45[0]	mndf10 [2]	etc.		etc.
								dfg[1]		z54537[1]	zfdf43 [0]	etc.		etc.
						----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
						Row[0] 		Sig: abc	L1: sdff45	L2: zfdf43	L3: addf45	L2_G1: addf45	L3_G01: addf45	L3_G1: addf45	L4: addf45	L4_G1: addf45	L4_G01: addf45	L5: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	Date :3494034304
						Row[1] 		Sig: dfg	L1: z54537	L2: bf4nnj	L3: addf45	L2_G1: addf45	L3_G01: addf45	L3_G1: addf45	L4: addf45	L4_G1: addf45	L4_G01: addf45	L5: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	Date :3494034304
						Row[2] 		Sig: cde	L1: abceff	L2: mndf10	L3: addf45	L2_G1: addf45	L3_G01: addf45	L3_G1: addf45	L4: addf45	L4_G1: addf45	L4_G01: addf45	L5: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	Date :3494034304
						Row[3] 		Sig: bbb	L1: saffa3	L2: addfzt	L3: addf45	L2_G1: addf45	L3_G01: addf45	L3_G1: addf45	L4: addf45	L4_G1: addf45	L4_G01: addf45	L5: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	Date :3494034304


			Child[1] gerfd3	(2300 Bytes)		
						ROW_INDEXES (2)
								bcd[0]		bsff13[0]	addf45[1]	etc.		etc.
								cde[1]		chf453[1]	zddf54[0]	etc.		etc.
						----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
						Row[0] 		Sig: bcd	L1: bsff13	L2: zddf54	L3: addf45	L2_G1: addf45	L3_G01: addf45	L3_G1: addf45	L4: addf45	L4_G1: addf45	L4_G01: addf45	L5: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	Date :3494034304
						Row[1]		Sig: cde	L1: chf453	L2: addf45	L3: addf45	L2_G1: addf45	L3_G01: addf45	L3_G1: addf45	L4: addf45	L4_G1: addf45	L4_G01: addf45	L5: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	Date :3494034304

			Child[2] mnopqc	(723 Bytes)	
						ROW_INDEXES (1)
								def[0]		fcf5jj[0]	addf45[1]	etc.		etc.
						----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
						Row[1] 		Sig: def	L1: fcf5jj	L2: addf45	L3: addf45	L2_G1: addf45	L3_G01: addf45	L3_G1: addf45	L4: addf45	L4_G1: addf45	L4_G01: addf45	L5: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	Date :3494034304


	Char[1] 101 (3177 Bytes) 
	CHILD_INDEXES (2)
			gerfd7[0] (0 Bytes)
			mnopqg[1] (446 Bytes)
			==========================================================================================================================================================================================================================================================================================================================================
			Child[0] gerfd7	(4834 Bytes)		
						ROW_INDEXES (2)
								abc[1]		hmmsl3[1]	addfhf[0]	etc.		etc.
								bcd[0]		kfff24[0]	zddf65[1]	etc.		etc.
						----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
						Row[1] 		Sig: bcd	L1: kfff24	L2: addfhf	L3: addf45	L2_G1: addf45	L3_G01: addf45	L3_G1: addf45	L4: addf45	L4_G1: addf45	L4_G01: addf45	L5: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	Date :3494034304
						Row[2] 		Sig: abc	L1: hmmsl3	L2: zddf65	L3: addf45	L2_G1: addf45	L3_G01: addf45	L3_G1: addf45	L4: addf45	L4_G1: addf45	L4_G01: addf45	L5: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	Date :3494034304


			Child[1] mnopqg (723 Bytes)	
						ROW_INDEXES (1)
								ndfl[0]		hmmsl3[0]	zddf65[0]	etc.		etc.
						----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

						Row[0] 		Sig: ndfl	L1: hmmsl3	L2: zddf65	L3: addf45	L2_G1: addf45	L3_G01: addf45	L3_G1: addf45	L4: addf45	L4_G1: addf45	L4_G01: addf45	L5: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	Date :3494034304
			
			


	Char[2] 116 (3405 Bytes) 
	CHILD_INDEXES (1)	
			mnostg[0] (0 Bytes)
			==========================================================================================================================================================================================================================================================================================================================================
			Child[0] mnostg (723 Bytes)	
						ROW_INDEXES (1)
								bcd [0]		fgs34l [0]	addf45 [0]	etc.		etc.
						----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
						Row[0] 		Sig: bcd	L1: fgs34l	L2: addf45	L3: addf45	L2_G1: addf45	L3_G01: addf45	L3_G1: addf45	L4: addf45	L4_G1: addf45	L4_G01: addf45	L5: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45	L2: addf45

			
		
<cortex:end>